package com.xuecheng.teaching.controller;

import com.xuecheng.commons.model.dto.Comment2Dto;
import com.xuecheng.commons.model.dto.CommentDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.CountVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.teaching.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class CommentController {

    @Autowired
    private CommentService commentService;


    //课程评论统计
    @GetMapping("/course-comment/course-statistics/{targetId}")
    public ResponseResult countById(@PathVariable("targetId") Long targetId) {
        return commentService.countById(targetId);
    }

    // 评论课程
    @PostMapping("/course-comment")
    public ResponseResult commentPub(@RequestBody CommentDto dto) {
        return commentService.commentPub(dto);
    }

    //课程评论列表
    @PostMapping("/course-comment/for-course")
    public ResponseResult commentList(PageRequest request, @RequestBody Comment2Dto dto) {
        return commentService.commentList(request, dto);
    }

    //查询评价列表
    @PostMapping("/course-comment/list")
    public ResponseResult list(PageRequest request, @RequestBody Comment2Dto dto) {
        return commentService.commentList(request, dto);
    }

    // 机构的评论列表
    @GetMapping("/course-comment/list-all")
    public ResponseResult listAll(PageRequest request) {
        return commentService.listAll(request);
    }


    // 机构模糊查询
    @GetMapping("/like")
    public ResponseResult like(@RequestParam("courseName") String courseName){
        return commentService.getLike(courseName);
    }





}
